/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package org.jmresler.sakila.domain;

import jakarta.persistence.*;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

@NoArgsConstructor
@Data
@Entity
@Table(schema = "sakila", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"rental_date", "inventory_id", "customer_id"})})
public class Rental implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "rental_id", nullable = false)
    private Integer rentalId;
    @Basic(optional = false)
    @Column(name = "rental_date", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date rentalDate;
    @Column(name = "return_date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date returnDate;
    @Basic(optional = false)
    @Column(name = "last_update", nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastUpdate;
    @JoinColumn(name = "customer_id", referencedColumnName = "customer_id", nullable = false)
    @ManyToOne(optional = false)
    private Customer customerId;
    @JoinColumn(name = "inventory_id", referencedColumnName = "inventory_id", nullable = false)
    @ManyToOne(optional = false)
    private Inventory inventoryId;
    @JoinColumn(name = "staff_id", referencedColumnName = "staff_id", nullable = false)
    @ManyToOne(optional = false)
    private Staff staffId;
    @OneToMany(mappedBy = "rentalId")
    private List<Payment> paymentList;

}
